In case we are in the same page do following
sudo apt-get install php -y
sudo apt-get install php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y
To enable PHP 7.2 FPM in Apache2 do:
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
update 2: Apache downloads .php file instead of rendering
After that, I faced above issue. There are similar questions like this.
I don't know why but it only happened for my .php files in /var/www/html/
root folder. everything was ok for sub-directories. (for example wordpress and phpmyadmin worked fine)
So here is my solution. I decided to enable php module. so I ran this command:
a2enmod php7.2
but I got this errors:
Considering dependency mpm_prefork for php7.2:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!
Considering conflict mpm_worker for mpm_prefork:
ERROR: Could not enable dependency mpm_prefork for php7.2, aborting
so I decided to disable mpm by running following commands:
sudo a2dismod mpm_prefork
sudo a2dismod mpm_worker
sudo a2dismod mpm_event
then restart apache:
systemctl restart apache2
then enable php7.2 (my installed version):
sudo a2enmod php7.2
and right now everything works fine.
<?
instead of<?php
? – Biracial<?
). They are deprecated, don't really work in a lot of places, and are otherwise completely unneccessary. Saving three keystrokes is not a valid reason to allow potential for your code to fail on probably half of the servers it may run on. – Azeria<?=
), which should run fine on php 5.4+ regardless of server settings. – Azeriatail -f -n 50 /var/log/apache2/error.log
helped me find the issue. – Henninger